



use "$data/survey1_clean.dta", clear

gen wave = 1

append using "$data/survey2_clean.dta"

replace wave = 2 if wave==.



gen anycase = anycase_march5 if wave==1
replace anycase = anycase_march16 if wave==2

global control male age_* log_inc log_inc_sq highschool college working student democrat republican 



loc experiments "z_impact_1 z_impact_2 z_worry_corona_econ z_worry_perecon"
		   
		  
preserve 

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments'   {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""

global output_coeff ""
global output_se ""
global output_name""

foreach choice in `experiments' {

/* Statistics */


	
	
reg `choice' anycase i.state i.wave $control, cluster(state)
    sigstar anycase, prec(4)
    estadd loc thisstat2 = "`r(bstar)'": col`colnum'
    estadd loc thisstat3 = "`r(sestar)'": col`colnum'
	
	estadd loc thisstat5 = string(`e(r2)', "%9.2f"): col`colnum'
	qui sum anycase 
	estadd loc thisstat6 =  r(N): col`colnum'
	
	
	

	estadd loc thisstat7 =  "X": col`colnum'
	estadd loc thisstat8 =  "X": col`colnum'
	estadd loc thisstat9 =  "X": col`colnum'


	loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"	


	} 
	

loc rowlabels " " "  "Any case" " "  " " "\midrule R$^2$" "Number of Observations" "\midrule Including controls" "State FE" "Survey FE" "
loc rowstats ""

forval i = 1/9 {
    loc rowstats "`rowstats' thisstat`i'"
}





esttab * using "$tables/DiD_survey.tex", replace cells(none) booktabs nonotes compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
   mtitle("World"  "US"  "US Economy" "Pers. Economic Sit." ) ///
   mgroups("Predicted impact on (standardized)" "Worry about (standardized)" ,  pattern(1 0   1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

    
   
   
